
//-----------------------------------------登录处理----------------------------------------------------
//pagecreate
		$("#login").live( "pageinit" , function(event){
			$("#userName").keypress(function(event){
				if( event.keyCode == 13 ){
					$("#userPwd").focus();
					return false;
				}				
			});
			
			$("#userPwd").keypress(function(event){
				if( event.keyCode == 13 ){
					$("#loginBtn").click();					
					return false;
				}
			});
				
			//提交事件
			$("#loginBtn").click(function(event){
				var name = $("#userName").val();
				var pwd = $("#userPwd").val();
				
				if( name.length <= 0 || pwd.length <= 0 ){
					$.mobile.changePage( $("#loginError") , { transition : "pop" ,changeHash: false ,  reloadPage : true  });
					return false;
				}				
				
				
				var url = $("#loginForm").attr("action");
			
				$.post( url , {
					userName : name,
					userPwd : pwd
				},function(data){
					//如果登录失败,则提示错误
					if( data == "error" ){
						$.mobile.changePage( $("#loginError") , { transition : "pop" ,changeHash: false ,  reloadPage : true  });
					}else if( data == "validateError" ){
						$.mobile.changePage($("#loginValidateError") , { transition : "pop" ,changeHash: false ,  reloadPage : true  });
					}else{			
						$.mobile.changePage( "/home.jsp" , { transition : "pop" ,changeHash: false ,  reloadPage : true  });
					}					
				},"text");				
				return false;
			}); //end loginBtn Event
			
			
			//重置事件
			$("#resetBtn").click(function(event){
				$("#userName").empty();
				$("#userPwd").empty();
				$("#userName").focus();
			});
});


$("#exitPage").live("pageinit",function(event){
	$("#exitBtnOk").click(function(){
		//logOut
		$.post( "mobile/Login" , {
			method : 'logOut',			
			time : new Date().getTime()
		} ,function(data){
			window.location.href="/";			
		},"text");
	});	
});